/*
 * Copyright 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.samples.apps.nowinandroid.demo.api

import com.google.samples.apps.nowinandroid.demo.model.MovieInfo
import com.google.samples.apps.nowinandroid.demo.model.MovieList
import retrofit2.http.GET
import retrofit2.http.Query
/**
 * OMDB API 接口
 * 用于与 OMDB 电影数据库 API 进行通信
 */
interface MovieApi {
    /**
     * 获取电影信息
     * @param apiKey OMDB API 密钥
     * @param title 电影标题
     * @return 返回电影详细信息
     */
    @GET("/")
    suspend fun getMovieInfo(
        @Query("apikey") apiKey: String,
        @Query("imdbID") imdbID: String,
        @Query("t") title: String
    ): MovieInfo

    /**
     * 获取电影列表信息
     * @param apiKey OMDB API 密钥
     * @param searchTitle 用于搜索的电影标题
     * @param type 结果类型（可选，movie、series、episode 等）
     * @param year 发行年份（可选）
     * @param page 页码（可选，1 - 100，默认为 1）
     * @return 返回电影列表相关信息
     */
    @GET("/")
    suspend fun getMovieList(
        @Query("apikey") apiKey: String,
        @Query("s") searchTitle: String,
        @Query("type") type: String? = null,
        @Query("y") year: String? = null,
        @Query("page") page: Int = 1
    ): MovieList

    companion object {
        /** OMDB API 的基础 URL */
        const val BASE_URL = "http://www.omdbapi.com/"
    }
}